#include <stdio.h>
#include <stdlib.h>

long sum(long arr[], int l, int r) {
    long sum = 0;
    for (int i = l; i <= r; i++)
        sum += arr[i];
    return sum;
}
#define MAX(a,b) ((a)>(b)? (a):(b))
long res = 0;   //最后结果

// 分割，舍弃和大的一边，将小的和加到res
void game(long arr[], int l, int r) {
    if (l > r) {
		return ;
	}
    int mid = (l+r-1)/2;
    long left = sum(arr, l, mid);
    long right = sum(arr, mid+1, r);
    if (left > right) { //左边和大，舍弃
        res += right;
        game(arr, mid+1, r);
    } else {
        res += left;
        game(arr, l, mid);
    }
}
int main(void) 
{
    int i, n = 6;
	long arr[6] = {6, 2, 3, 4, 5, 5};
    game(arr, 0, n-1);
    printf("%d\n",res);
    return 0;    
}